import requests
import app


class LoginAPI:
    def __init__(self):
        self.login_url = app.BASE_URL + "/index.php?m=Home&c=User&a=do_login"
        self.verify_url = app.BASE_URL + "/index.php?m=Home&c=User&a=verify"

    def get_code(self, session):
        return session.get(url=self.verify_url)

    def Login(self, login_data, session):
        return session.post(url=self.login_url, data=login_data)

# if __name__ == '__main__':
#     login_api = LoginAPI()
#     login_data = {
#         "username": "13588888888",
#         "password": "123456",
#         "verify_code": "8888"
#     }
#     session = requests.session()
#     login_api.get_code(session)
#     response = login_api.Login(login_data, session)
#     print(response.json())
